<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head th:include="include :: header"></head>
<style>
    #toast-container .toast-warning{
        width:800px;
    }
    #toast-container .toast-message div{
        width:700px;
    }
</style>
<body class="hold-transition skin-blue sidebar-mini">

<section class="content-header">
    <h1>
        原料库入库单
    </h1>
</section>
<section class="content">
    <form id="inBillForm" role="form"
          enctype="multipart/form-data">
        <div class="row">
            <div class="col-xs-12">
                <div class="box">
                    <div class="box-body">
                        <div class="row">
                            <div class="form-inline">
                                <div class="form-group">
                                    <label>入库类型</label>
                                    <select id="odrType" name="odrType" class="form-control">
                                        <option value="" selected="selected">请选择</option>
                                        <option value="1">采购入库</option>
                                        <option value="2">退料入库</option>
                                    </select>
                                </div>
                                <div class="form-group">
                                    <label>库位</label>
                                    <select id="odrWhiId" class="form-control" name="odrWhiId">
                                        <option value="">请选择</option>
                                        <option th:each="type:${warehouse}" th:value="${type.whiId}"
                                                th:text="${type.whiName}"
                                                th:selected="${type.whiName eq '原料库'}"></option>
                                    </select>
                                </div>
                                <div class="form-group">
                                    <label>签收单回货日期</label>
                                    <input type="text" class="form-control datepicker" th:value="${odrDate}"
                                           id="odrDate" name="odrDate" readonly="readonly"/>
                                </div>
                                <div class="form-group">
                                    <label>经手人</label>
                                    <input id="odrTakePerson" type="text" class="form-control" name=""
                                           placeholder=""
                                           autocomplete="off"/>
                                </div>
                                <div class="form-group">
                                    <label>摘要</label>
                                    <input id="odrRemark" type="text" class="form-control" name="" placeholder=""
                                           autocomplete="off"/>
                                </div>
                                <div class="form-group">
                                    <label>模板下载</label>
                                    <a th:href="@{/file/原料入库单据导入模板.xlsx}">入库单据导入模板.xlsx</a>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div id="hot"></div>
                        </div>
                    </div>
                    <div class="box-footer">
                        <div class="row">
                            <div class="col-md-2">
                                <label>制单人：</label><label th:text="${odrMakePerson}"></label>
                            </div>
                            <div class="col-md-6">
                                <label></label>
                            </div>
                            <div class="col-md-4">
                                <div class="col-md-2 col-md-offset-7">
                                </div>
                                <div class="col-md-2">
                                    <button shiro:hasPermission="matwar:matinwar:edit" type="button" id="btn-save"
                                            class="btn btn-info file-contract btn-file">保存
                                    </button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </form>
</section>
<div th:include="include :: footer"></div>
<script th:inline="javascript">

    $(function () {

        var process = function (data) {

            if ($("#odrType").val() == "") {
                js.modal.warning("请选择入库类型！");
                $("#odrType").focus();
                return;
            }

            if ($("#odrWhiId").val() == "") {
                js.modal.warning("请选择入库仓库！");
                $("#odrWhiId").focus();
                return;
            }

            if ($.isEmptyObject(data.insertData)) {
                js.modal.warning("入库明细不允许为空！");
                return;
            }

            js.post({
                url: ctx + "material/order/inCreate",
                data: JSON.stringify(data),
                contentType: "application/json",
                success: function (result) {
                    if (result.type === web_status.SUCCESS) {
                        js.modal.success(result.msg);
                        js.hot.loadData([]);
                    } else {
                        js.modal.warning(result.msg);
                    }
                    js.modal.closeLoading();
                }
            })

        }

        /**表单加载*/
        js.hot.init({
            element: document.getElementById('hot'),
            data: {},
            formData: ["odrType", "odrTakePerson", "odrRemark", "odrDate", "odrWhiId"],
            colHeaders: ['ID', '类型', '材质', '规格', '宽度', '长度', '米重/厚度', '数量', '重量', '单价', '跟踪号', '项目编号', '项目名称','供应商','合同编号','区位', '在库类型', '回货时间', '回货重量', '特殊说明', 'SAP物料编码'],
            fieldName: ['odaId', 'matType', 'matQuality', 'matSpec', 'matWidth', 'matLength', 'matHeight', 'odaNum', 'odaWeight', 'odaPrice', 'odaTrackCode', 'odaProCode', 'odaProName','supplier','contractNo', 'odaPosition','odaInTypeName', 'odaBackDate', 'odaBackWeight', 'odaSpec', 'odaMatSapCode'],
            height: 700,
            correctFormat: true,
            minSpareRows: 100,
            hiddenColumns: {
                columns: [0],
                indicators: true
            },
            callBack: process,
            saveButtonId: $("#btn-save"),
            columns: [
                {
                    data: 'Id',
                    type: 'numeric',
                    width: 40
                },
                {
                    data: 'matType',
                    type: 'text'
                },
                {
                    data: 'matQuality',
                    type: 'text'
                },
                {
                    data: 'matSpec',
                    type: 'text'
                },
                {
                    data: 'matWidth',
                    type: 'numeric'
                },
                {
                    data: 'matLength',
                    type: 'numeric'
                },
                {
                    data: 'matHeight',
                    type: 'numeric'
                },
                {
                    data: 'odaNum',
                    type: 'numeric'
                },
                {
                    data: 'odaWeight',
                    type: 'numeric'
                },
                {
                    data: 'odaPrice',
                    type: 'numeric'
                },
                {
                    data: 'odaTrackCode',
                    type: 'text'
                },
                {
                    data: 'odaProCode',
                    type: 'text'
                },
                {
                    data: 'odaProName',
                    type: 'text'
                },
                {
                    data: 'supplier',
                    type: 'text'
                },
                {
                    data: 'contractNo',
                    type: 'text'
                },
                {
                    data: 'odaPosition',
                    type: 'text'
                },
                {
                    data: 'odaInTypeName',
                    type: 'dropdown',
                    source: ['库存在库', '项目在库']
                },
                {
                    data: 'odaBackDate',
                    type: 'text'
                },
                {
                    data: 'odaBackWeight',
                    type: 'text'
                },
                {
                    data: 'odaSpec',
                    type: 'text'
                },
                {
                    data: 'odaMatSapCode',
                    type: 'text'
                }
            ]
        })

    })

</script>


</body>
</html>